var t = require("../../../@babel/runtime/helpers/objectWithoutProperties"), a = [ "url" ], e = getApp();

Page({
    data: {
        article_list: [],
        base: {},
        logo_url: "",
        userList: [],
        showSearch: !0,
        catalogueProps: {},
        plugin: "message-base",
        base_id: 0
    },
    onLoad: function(t) {
        if (!t.bid) return e.tips("缺少必要参数！");
        this.data.base_id = t.bid, this.data.userList = [], this.init(), this.getdata();
    },
    init: function() {
        var t = this, a = new Map([ [ "message-base", {
            index: "plugin.message-base.frontend.article.baseArticle",
            params: function() {
                return {
                    base_id: t.options.bid
                };
            },
            showSearch: !0,
            list: {
                label: "article_list",
                children: "article_name"
            },
            catalogueProps: {
                label: "article_name",
                children: "child"
            },
            callback: function(t) {}
        } ], [ "project-template", {
            index: "plugin.project-template.frontend.knowledge.knowledgeBaseCatalog",
            params: function() {
                return {
                    id: t.options.bid
                };
            },
            showSearch: !1,
            list: {
                label: "knowledgeBaseArticle",
                children: "title"
            },
            catalogueProps: {
                label: "title",
                children: "has_many_yz_supply_knowledge_base_article"
            },
            callback: function(t) {}
        } ] ]);
        this.options.plu && (this.data.plugin = this.options.plu), this.data.apiOption = a.get(this.data.plugin), 
        this.setData({
            catalogueProps: this.data.apiOption.catalogueProps,
            showSearch: this.data.apiOption.showSearch
        });
    },
    getdata: function() {
        var t = this, a = (this.options.bid, e.getNetAddresss(this.data.apiOption.index));
        e._getNetWork({
            url: a,
            data: this.data.apiOption.params(),
            success: function(a) {
                var e = a.data;
                1 === e.result ? (t.data.article_list = e.data[t.data.apiOption.list.label] || [], 
                t.data.article_list = t.data.article_list.filter(function(a) {
                    return "" != a[t.data.apiOption.list.children];
                }), e.data.manager_list && t.data.userList.push(e.data.manager_list || {}), t.data.userList = t.data.userList.concat(e.data.member_list || []), 
                t.setData({
                    logo_url: e.data.logo,
                    article_list: t.data.article_list,
                    base: e.data.base,
                    userList: t.data.userList
                })) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            }
        });
    },
    toUrl: function(t) {
        var a = t.currentTarget.dataset || {};
        this.wxRouterLink(a);
    },
    wxRouterLink: function(e) {
        var i = "", s = e.url, n = t(e, a);
        Object.keys(n).forEach(function(t) {
            "" !== n[t] && (i += t + "=" + n[t] + "&");
        }), "" !== s && wx.navigateTo({
            url: s + "?" + i.slice(0, -1)
        });
    },
    treeTap: function(t) {
        var a = t.detail.item.id;
        this.wxRouterLink({
            url: "/packageI/knowledge/knowledgeDetail/knowledgeDetail",
            id: a,
            bid: this.data.base_id,
            plu: this.data.plugin
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        var t = wx.getStorageSync("yz_uid"), a = "";
        return t && (a = t), {
            path: "/packageI/knowledge/knowledgeList/knowledgeList?plu=" + this.options.plu + "&bid=" + this.options.bid + "&mid=" + a
        };
    }
});